package com.tjetc.dao.impl;

import com.tjetc.dao.OtcDao;
import com.tjetc.domain.Otc;
import com.tjetc.utils.Db;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class OtcDaoImpl implements OtcDao {
    @Override
    public int add(Otc otc) throws SQLException {
        return Db.runner0().update("insert into otc(rid, name, mid, num, remarks) VALUES (?,?,?,?,?)",
                otc.getRid(),otc.getName(),otc.getMid(),otc.getNum(),otc.getRemarks());
    }

    @Override
    public List<Otc> listByRid(int rid) throws SQLException {
        return Db.runner0().query("select * from otc where rid = ?",new BeanListHandler<>(Otc.class),
                rid);
    }
}
